/**
 * Created by vicket on 2017/4/21.
 */
$(function(){
    var novelId=sessionStorage.getItem("bookId");
    $('.back').attr('href','noveldetail.ejs#'+novelId);
    var commentList=$(".comment_list");
    $.ajax({
        type:"get",
        url:"/api/frontGetAllComment",
        data:{bookId:novelId},
        success:function(result){
            var html=template("commentTem",{"items":result});
            commentList.html(html);
            //���޹���
            var upvote=$(".upvote");
            for(var i=0;i<upvote.length;i++){
                upvote[i].index=i;
            }
            upvote.on("touchstart",function(){
                var _this=this;
                $.ajax({
                    type:"get",
                    url:"/api/addGood",
                    data:{auditId:result[_this.index].auditId},
                    success:function(res){
                        console.log(res);
                        $.ajax({
                            type:"get",
                            url:"/api/frontGetComment",
                            data:{bookId:novelId},
                            success:function(result){
                                $(_this).text(result[_this.index].good);
                            }
                        })
                    }
                })
            })
        }
    })
})